package com.trkj.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class LoginInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session = request.getSession();
		System.err.println(session.getAttribute("staffNo")+"----999");
		if(session.getAttribute("staffNo") == null){
			//还没有登陆
			request.getRequestDispatcher("toLogin").forward(request, response);
			return false;
		}else{
			//已经登陆
			return true;
		}
	}
}
